import json as json_object


def build_success_result(imageUrl:str,uniqueId:str,result:list,ocr_result=None,qr_result=None,content_summary=""):
    response_data = {
        "extInfo": "",
        "msg": "",
        "code":200,
        "data":{
            "imageUrl": imageUrl,
            "uniqueId": uniqueId,
            "result":result,
            "ocrResult":ocr_result,
            "qrResult":qr_result,
            "contentSummary" : content_summary
        }
    }
    return response_data



def build_batch_success_result(result_datas:list):
    response_data={
        "extInfo": "处理成功！",
        "code": 200,
        "msg": "处理成功！",
        "data": result_datas
    }
    return response_data




def build_success_msg_result(msg):
    response_data={
                "extInfo": msg,
                "code": 200,
                "msg": msg,
                "data": None
    }
    return response_data

def build_fail_result(e,msg):
    errorMsg=msg if msg else str(e)
    response_data={
        "extInfo": errorMsg,
        "code":  500,
        "data": None,
        "msg": f"接口执行异常:{errorMsg}"
    }
    return response_data




def build_classfy_obj(classifyName:str,subClassifyName:str,confidence:float):
    '''
    构建分类对象
    classifyName：一级分类没成
    subClassifyName：二级分类名称
    confidence：置信度，即该分类得可信程度
    返回
     {
        "classifyName": "卡证",
        "subClassifyName": "身份证",
        "confidence": 1.0
     }
    '''
    classfy_obj=dict()
    classfy_obj["classifyName"]=classifyName
    classfy_obj["subClassifyName"]=subClassifyName
    classfy_obj["thirdClassifyName"] = subClassifyName
    classfy_obj["confidence"]=confidence
    return classfy_obj
def build_classfy_third_obj(classifyName:str,subClassifyName:str,thirdClassifyName:str,confidence:float):
    '''
    构建分类对象
    classifyName：一级分类没成
    subClassifyName：二级分类名称
    confidence：置信度，即该分类得可信程度
    返回
     {
        "classifyName": "生物",
        "subClassifyName": "",
        "thirdClassifyName": ""
        "confidence": 1.0
     }
    '''
    classfy_obj = dict()
    classfy_obj["classifyName"] = classifyName
    classfy_obj["subClassifyName"] = subClassifyName
    classfy_obj["thirdClassifyName"] = thirdClassifyName
    classfy_obj["confidence"] = confidence
    return classfy_obj
